home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Camelot
/
Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].zip
/
Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].adf
/
XLisp-Stat
/
Functions
/
twobutton.lsp
< prev
Wrap
Text File
|
1990-10-11
|
2KB
|
62 lines
; book pp.317-320
(require "functions/pressbutton")
(defproto twobutton-control-proto () () button-overlay-proto)
(defmeth twobutton-control-proto :size ()
(let* ((graph (send self :graph))
(size (call-next-method))
(side (send graph :text-ascent))
(gap (floor (/ side 2))))
(list (+ gap side (first size)) (second size))))
(defmeth twobutton-control-proto :title-start ()
(let* ((graph (send self :graph))
(loc (send self :location))
(title (send self :title))
(side (send graph :text-ascent))
(gap (floor (/ side 2))))
(list (+ (* 3 gap) (* 2 side) (first loc))
(+ gap side (second loc)))))
(defmeth twobutton-control-proto :button-box (which)
(let* ((graph (send self :graph))
(loc (send self :location))
(side (send graph :text-ascent))
(gap (floor (/ side 2)))
(left (case which
(+ (+ gap (first loc)))
(- (+ (* 2 gap) side (first loc))))))
(list left (+ gap (second loc)) side side)))
(defmeth twobutton-control-proto :draw-button (which &optional paint)
(let ((box (send self :button-box which))
(graph (send self :graph)))
(cond (paint (apply #'send graph :paint-rect box))
(t (apply #'send graph :erase-rect box)
(apply #'send graph :frame-rect box)))))
(defmeth twobutton-control-proto :redraw ()
(send self :draw-title)
(send self :draw-button '-)
(send self :draw-button '+))
(defmeth twobutton-control-proto :point-in-button (x y)
(let* ((box1 (send self :button-box '-))
(box2 (send self :button-box '+))
(left1 (first box1))
(top (second box1))
(side (third box1))
(left2 (first box2)))
(cond
((and (< left1 x (+ left1 side)) (< top y (+ top side)))
'-)
((and (< left2 x (+ left1 side)) (< top y (+ top side)))
'+))))
(defmeth twobutton-control-proto :do-click (x y m1 m2)
(let ((graph (send self :graph))
(which (send self :point-in-button x y)))
(when which
(send self :draw-button which t)
(send self :do-action which (list m1 m2))
(send graph :while-button-down
#'(lambda (x y) (send self :do-action which nil)) nil)
(send self :draw-button which nil)
t)))
(defmeth twobutton-control-proto :do-action (which mods) nil)